import 'package:dio/dio.dart';
import 'package:dio_log/interceptor/dio_log_interceptor.dart';
import 'package:network_logger/network_logger.dart';
import 'package:pretty_dio_logger/pretty_dio_logger.dart';
import 'package:regsiter_center/register_model.dart';
import 'package:regsiter_center/register_center_helper.dart';
import 'package:user_data_model/user_data_model.dart';
import 'package:user_data_model/user_register_item.dart';

/**
 *
 * @ProjectName:    person_model_project
 * @ClassName:      app
 * @Description:    dart类作用描述
 * @Author:         孙浩
 * @QQ:             243280864
 * @CreateDate:     2021/1/8 5:29 PM
 */
class App{
  static RegisterCenterHelper registerCenterHelper = RegisterCenterHelper();
  static UserRegister _userModel;
  static Dio dio;
  static initAppConfig(){
    dio = Dio(
      BaseOptions(contentType: Headers.jsonContentType)
    );
    initDioConfig();
    _userModel = UserRegister.instance..initDio(dio);

    registerCenterHelper.initModel(MainModel());
    registerCenterHelper.initModel(_userModel);
  }

  static void initDioConfig() {
    dio.interceptors.add(DioLogInterceptor());
    dio.interceptors.add(PrettyDioLogger());
    dio.interceptors.add(DioNetworkLogger());
  }

  static UserRegister get userModel => _userModel;
}
class MainModel extends RegisterModel{


  @override
  unbindToken() {
  }

  @override
  bindToken(String token, String refreshToken) async {
    await UserDataPlugin.initRefreshToken(refreshToken);
  }

}